package com.example.administrator.jingpingou.fragment;

import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;

import com.example.administrator.jingpingou.R;

/**
 * Created by Administrator on 2016/8/28 0028.
 */
public class XianshiFragment extends Fragment {
    private RadioGroup mRadioGroup;
    private RadioButton mRadioButton7,mRadioButton9,mRadioButton12,mRadioButton15,mRadioButton18,mRadioButton21;
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_xianshi, null);
       iniView(view);
        setListener();
        return view;
    }
    public void iniTextColor(){
        mRadioButton7.setTextColor(Color.WHITE);
        mRadioButton9.setTextColor(Color.WHITE);
        mRadioButton12.setTextColor(Color.WHITE);
        mRadioButton15.setTextColor(Color.WHITE);
        mRadioButton18.setTextColor(Color.WHITE);
        mRadioButton21.setTextColor(Color.WHITE);

    }

    private void setListener() {
        mRadioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                switch (checkedId) {
                    case  R.id.rg_xianshi_7:
                      iniTextColor();
                        mRadioButton7.setTextColor(getActivity().getResources().getColor(R.color.colorText));
                        break;
                    case R.id.rg_xianshi_9:
                        iniTextColor();
                        mRadioButton9.setTextColor(getActivity().getResources().getColor(R.color.colorText));
                        break;
                    case R.id.rg_xianshi_12:
                        iniTextColor();
                        mRadioButton12.setTextColor(getActivity().getResources().getColor(R.color.colorText));
                        break;
                    case R.id.rg_xianshi_15:
                        iniTextColor();
                        mRadioButton15.setTextColor(getActivity().getResources().getColor(R.color.colorText));

                        break;
                    case R.id.rg_xianshi_18:
                        iniTextColor();
                        mRadioButton18.setTextColor(getActivity().getResources().getColor(R.color.colorText));
                        break;
                    case R.id.rg_xianshi_21:
                        iniTextColor();
                        mRadioButton21.setTextColor(getActivity().getResources().getColor(R.color.colorText));
                        break;
                }
            }
        });
    }

    private void iniView(View view) {
        mRadioGroup= (RadioGroup) view.findViewById(R.id.rg_xianshi_group);
        mRadioButton7= (RadioButton) view.findViewById(R.id.rg_xianshi_7);
        mRadioButton9= (RadioButton) view.findViewById(R.id.rg_xianshi_9);
        mRadioButton12= (RadioButton) view.findViewById(R.id.rg_xianshi_12);
        mRadioButton15= (RadioButton) view.findViewById(R.id.rg_xianshi_15);
        mRadioButton18= (RadioButton) view.findViewById(R.id.rg_xianshi_18);
        mRadioButton21= (RadioButton) view.findViewById(R.id.rg_xianshi_21);

    }
}
